//
//  HMBaseTableViewController.swift
//  Weibo
//
//  Created by 京城 on 16/7/18.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class HMBaseTableViewController: UITableViewController {

    var isLogin = false
    
    override func loadView() {
        
        if(isLogin){
            super.loadView()
            
        }else{
            
            let view = UIView()
            view.backgroundColor = UIColor.brownColor()
            self.view = visitorView
            
            visitorView.delegate = self
            if self is HMHomeTableViewController{
                
                visitorView.imgeRotate()
            }else if self is HMMessageTableViewController{
                visitorView.setupVistorInfo("visitordiscover_image_message", title: "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
            }else if self is HMDiscoveryTableViewController{
                
                visitorView.setupVistorInfo("visitordiscover_image_message", title: "我的据了解电路设计路附近的流口水尽量快点睡觉的")
            }else if self is HMProfileTableViewController{
                
                visitorView.setupVistorInfo("visitordiscover_image_profile", title: "世界诶飞机哦时间将诶手机覅就是倒速度的")
            }
            
        }
        
        
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewDidRegister")
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewDidLogin")
    }

    lazy var visitorView: HMVisitorView = HMVisitorView()
    
}

extension HMBaseTableViewController:visitorViewDelegate {
    
    func visitorViewDidRegister(){
        
        
    }
    
    func visitorViewDidLogin(){
        
        let oauthVC = HMOauthViewController()
        
        self.presentViewController(UINavigationController(rootViewController: oauthVC), animated: true, completion: nil)
    }
    
}


